package com.google.code.kjug.guava.app;

import com.google.code.kjug.guava.app.domain.Car;
import com.google.code.kjug.guava.app.domain.Make;
import com.google.common.collect.Sets;
import org.junit.Ignore;
import org.junit.Test;

import java.util.Set;

import static junit.framework.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;

public class Easy_UT {

    @Test
    @Ignore
    public void youGetWhatYouGive() {
        //

        Car car = new Car(2002, Make.JEEP, "Wrangler");

        assertEquals(2002, car.getYear());
        assertEquals(Make.JEEP, car.getMake());
        assertEquals("Wrangler", car.getModel());
    }

    @Test
    @Ignore
    public void yourCarShouldLookLikeThisAsAString() {
        Car car = new Car(2002, Make.JEEP, "Wrangler");

        String carString = car.toString();

        assertEquals("2002 Jeep Wrangler", carString);
    }

    @Test
    @Ignore
    public void yourCarShouldOnlyBeEqualIfSameYearModelAndMake() {
        Car car = new Car(2002, Make.JEEP, "Wrangler");
        Car differentCar = new Car(2001, Make.JEEP, "Wrangler");

        boolean equals = car.equals(differentCar);

        assertThat(equals, is(false));
    }

    @Test
    @Ignore
    public void yourCarShouldEqualIfItHasTheSameStuff() {
        Car car = new Car(2002, Make.JEEP, "Wrangler");
        Car differentCar = new Car(2002, Make.JEEP, "Wrangler");

        boolean equals = car.equals(differentCar);

        assertThat(equals, is(true));
    }

    @Test
    @Ignore
    public void watchOutForNullsInTheEqualsMethod() {
        Car car = new Car(2002, Make.JEEP, "Wrangler");
        Car differentCar = new Car(2002, Make.JEEP, null);

        boolean equals = car.equals(differentCar);

        assertThat(equals, is(false));
    }

    @Test
    @Ignore
    public void makeSureYouMakeAGoodHashCode() {
        //

        Set<Car> set = Sets.<Car>newHashSet(new Car(2002, Make.JEEP, "Wrangler"));
        Set<Car> differentSet = Sets.<Car>newHashSet(new Car(2002, Make.HONDA, "Accord"));

        assertThat(set.hashCode(), is(not(differentSet.hashCode())));
    }
}
